package org.raymond.iworks.study.basic.designpattern.state;

import lombok.Getter;
import lombok.Setter;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
@Getter
@Setter
public class RaffleActivity {
    private State noRaffleState = new NoRaffleState(this);
    private State canRaffleState = new CanRaffleState(this);
    private State dispenseState = new DispenseState(this);
    private State dispenseOutState = new DispenseOutState(this);
    // 当前状态
    private State state;
    // 奖品数量
    private int count;

    public RaffleActivity(int count){
        this.state = getCanRaffleState();
        this.count = count;
    }

    public void deduceMoney(){
        state.deduceMoney();
    }
    public void raffle(){
        if(state.raffle()){
            state.dispensePrize();
        }
    }

    public void setState(State state){
        this.state = state;
    }

    public void reducePrizeCount(){
        count--;
    }
}
